package cc.mrbird.febs.common.validator;

import com.wuwenze.poi.validator.Validator;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author : dtwei
 * @version : 1
 * @date : 2019/9/24 16:22
 */
public class MobileValidator implements Validator {

    @Override
    public String valid(Object o) {
        String MOBILE_REG = "(^0\\d{2,3}-\\d{7,8}$)|(^[1]\\d{10}$)";
        Pattern pattern = Pattern.compile(MOBILE_REG);
        Matcher matcher = pattern.matcher((String)o);
        if(!matcher.matches()) {
            return "联系方式格式错误，请检查联系方式";
        }
        return null;
    }
}